﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <script src="../JS/layer/layer.m.js"></script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="../JS/MobileCom.js?v=1.1"></script>
    <script src="../JS/avalon.mobile.min.js"></script>
    
    <title>报销明细</title>
    <style>
        .ui-tab-content {
            margin-top: 0px;
        }
        .ui-border {
            padding: 10px;
        }

        .ui-list > li {
            margin: 3px;
        }

        .ui-border {
            background-color: #fff;
        }

            .ui-border .v {
                border-top: solid 1px #ede8e8;
                padding: 5px;
                margin-top: 10px;
                font-size: 12px;
            }

                .ui-border .v span {
                    font-size: 10px;
                    float: right;
                }

        .ui-label-s {
            margin-right: 5px;
        }

        .ms-controller, [ms-controller] {
            display: none;
        }
    </style>
    <script>
        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
            //隐藏右上角按钮
            WeixinJSBridge.call('hideOptionMenu');
        });

        //if (MobileCom.getCookie("szhlcode") == null) {
        //    MobileCom.setCookie("szhlcode", "b2a7c203-16b1-4aed-9fe7-d3d147e963f9", 7);
        //}

        var bxmodel = avalon.define({
            $id: "sflist",
            ctData: [],
            ids:"",
            sq: function () {
                getid();
                if (bxmodel.ids == "")
                {
                    $.tips({
                        content: "请选择报销明细",
                        stayTime: 2000,
                        type: "warn"
                    })
                }
                else
                {
                    window.location.href = "UI_JFBX_SUBMIT.html?ids=" + bxmodel.ids + "&r=" + Math.random();
                }
            },
            sc: function () {
                getid();
                if (bxmodel.ids == "") {
                    $.tips({
                        content: "请选择报销明细",
                        stayTime: 2000,
                        type: "warn"
                    })
                }
                else {
                    var tc = layer.open({
                        content: '确定要删除报销明细吗？',
                        btn: ['确定', '取消'],
                        shadeClose: false,
                        yes: function () {
                            layer.close(tc);
                            var lg=$.loading({
                                content: '删除中...',
                            })
                            $.getJSON('/API/WXAPI.ashx?Action=DELJFBXITEM', { P1: bxmodel.ids }, function (resultData) {
                                lg.hide();
                                if (resultData.ErrorMsg == "") {
                                    $(".ui-footer").hide();
                                    var el = $.tips({
                                        content: "删除成功",
                                        stayTime: 2000,
                                        type: "success"
                                    })
                                    el.on("tips:hide", function () {
                                        //window.location.reload();
                                        window.location.replace(location.href);
                                    })
                                }
                                else {
                                    $.tips({
                                        content: "删除失败，原因：" + resultData.ErrorMsg,
                                        stayTime: 2000,
                                        type: "warn"
                                    })
                                }
                            })
                        }, no: function () {
                        }
                    })
                }
            }
        });

        avalon.ready(function () {
            var lg = $.loading({
                content: '加载中...',
            })
            $.getJSON("/API/WXAPI.ashx?Action=GETJFBXITEMLIST&r="+Math.random(), {}, function (r) {
                lg.hide();
                if (r.ErrorMsg == "") {
                    bxmodel.ctData.pushArray(r.Result);
                }
            })
        })

        function getid()
        {
            bxmodel.ids="";
            $("input[type=checkbox]:checked").each(function () {
                if (bxmodel.ids == "") {
                    bxmodel.ids = $(this).val();
                }
                else {
                    bxmodel.ids = bxmodel.ids + "," + $(this).val();
                }
            })
        }

    </script>
  
</head>
<body ms-controller="sflist">
    <header class="ui-header ui-header-stable ui-border-b">
        <h1>报销明细</h1><a class="ui-btn ui-btn-primary" href="UI_JFBX_BXMX_INPUT.html" style="color:white">新增</a>
    </header>
    <div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
        <button class="ui-btn-lg" onclick="history.back(-1)">
            取消
        </button>
        <button class="ui-btn-lg ui-btn-primary" ms-click="sq()">
            申请报销
        </button>
        <button class="ui-btn-lg ui-btn-danger" ms-click="sc()">
            删除明细
        </button>
    </div>

    <section class="ui-container">

        <div class="ui-form ui-border-t">
            <ul class="ui-list ui-list-pure" style="background-color:#f6f0f0;" >
                <li class="ui-border ui-label-list" ms-repeat-el="ctData">
                    <p>
                        <span class="ui-txt-info">
                            <label class="ui-label-s">
                                {{el.LeiBie}}
                            </label> {{el.BXJE}}元 {{el.BXDate|date("yyyy-MM-dd")}}
                        </span>
                        <span style="float:right">
                            <label class="ui-checkbox">
                                <input type="checkbox" ms-value='{{el.ID}}'>
                            </label>
                        </span>
                    </p>
                    <p class="ui-txt-justify">事由：{{MobileCom.convstr (el.BXContent,40)}}</p>
                </li>
            </ul>
        </div>


    </section>


</body>
</html>
